(function(K) {
    
var Assert = YAHOO.util.Assert;
var ArrayAssert = YAHOO.util.ArrayAssert;

function getDependencies(callback) {
    K.classLoader().
    requires("tk.k90tools.lang.Object").
    load(function(I) { callback(I); });
}
    
K.classLoader(K.data("testConfig").basePath).
provides("tk.k90tools.lang.ObjectTest").
load(function(I) {

    return function() {
        var test = new YAHOO.tool.TestCase({
        	
    		testPrototypeOf : function() {
        		getDependencies(function (I) {
        			test.resume(function() {
            			var f = function() {};
            			var o = new f();
            			Assert.areSame(I.Object.prototypeOf(o), f.prototype);
        			});
        		});
        		test.wait();
	        },		

	        testOwnKeys : function() {
        		getDependencies(function (I) {
        			test.resume(function() {
            			var f = function() {};
            			f.prototype.p1 = true;
            			
            			var o = new f();
            			o.p2 = true;
            			
            			var keys = I.Object.ownKeys(o);
            			ArrayAssert.itemsAreEqual(["p2"], keys);
        			});
        		});
        		test.wait();
	        },
		
			testCreate : function() {
        		getDependencies(function (I) {
        			test.resume(function() {
        				var o1 = {};
        				o1.p1 = {};
        				var o2 = I.Object.create(o1, {"p2" : {}});

        				Assert.areSame(o1.p1, o2.p1);
        				Assert.isFalse(Object.prototype.hasOwnProperty.call(o2, "p1"));
        				Assert.isTrue(Object.prototype.hasOwnProperty.call(o2, "p2"));
        			});
        		});
        		test.wait();
			},
			
			testKeys : function() {
        		getDependencies(function (I) {
        			test.resume(function() {
            			var f = function() {};
            			f.prototype.p1 = true;
            			
            			var o = new f();
            			o.p2 = true;
            			
            			var keys = I.Object.keys(o);
            			ArrayAssert.containsItems(["p1", "p2"], keys);
            			Assert.areSame(2, keys.length);
        			});
        		});
        		test.wait();
			},
			
			testHasOwnProperty : function() {
        		getDependencies(function (I) {
        			test.resume(function() {
            			var f = function() {};
            			f.prototype.p1 = true;
            			
            			var o = new f();
            			o.p2 = true;
            			
            			Assert.isTrue(I.Object.hasOwnProperty(o, "p2"));
            			Assert.isFalse(I.Object.hasOwnProperty(o, "p1"));
        			});
        		});
        		test.wait();				
			},
			
			testIsPrototypeOf : function() {
        		getDependencies(function (I) {
        			test.resume(function() {
            			var f = function() {};
            			var o = new f();
            			Assert.isTrue(I.Object.isPrototypeOf(f.prototype, o));
        			});
        		});
        		test.wait();
			},
			
			testForEachOwnProperty : function() {
				getDependencies(function(I) {
					test.resume(function() {
						var t = {};
						var o = {
							a:null
						};
						
						var passed = false;
						var f = function(k, o) {
							Assert.isFalse(passed);
							passed = true;
							
							Assert.areSame(k, "a");
							Assert.areSame(o[k], null);
							Assert.areSame(this, t);
						};
						
						I.Object.forEachOwnProperty(o, f, t);
						
					})
				});
				
				test.wait();
			}
            	
        });
        
        return test;
    }

});

})(k90tools);